<?php

namespace api\modules\v1\controllers;

use yii\filters\AccessControl;
use yii\filters\auth\QueryParamAuth;
use yii\helpers\ArrayHelper;

class OrderController extends BaseController {

    public $modelClass = 'api\modules\v1\models\Order';

    public function behaviors() {
        return ArrayHelper::merge(parent::behaviors(), [
            'authenticator' => [
                'class' => QueryParamAuth::className(),  //访问认证：请求参数access-token方式
            ],
        ]);
    }

    /**
     * 用户个人订单列表
     */
    public function actionIndex(){
        $modelClass = $this->modelClass;
        return $modelClass::queryAll();
    }

    public function actionUpdate($id) {
        $modelClass = $this->modelClass;
        return $modelClass::updateOrder($id); // TODO: Change the autogenerated stub
    }

    /**
     * 用户在未支付前取消订单或支付完成后删除订单
     * @param $id
     */
    public function actionDelete($id){
        $modelClass = $this->modelClass;
        return $modelClass::deleteOrder($id); // TODO: Change the autogenerated stub
    }
}
